package com.design.framework.activemq.producer;

import javax.annotation.Resource;
import javax.jms.Destination;

import org.springframework.jms.core.JmsTemplate;

/**
 * 消息生产者
 * 
 * @author JohnDeng 2019年1月15日下午2:19:04
 *
 */
public class QueueProducer {

	@Resource
	private JmsTemplate jmsTemplate;

	@Resource
	private Destination queueTextDestination;

	/**
	 * 发送文本消息 new MessageCreator() { public Message createMessage(Session session)
	 * throws JMSException { return session.createTextMessage(text); }
	 * 
	 * @param text
	 */
	public void sendTextMessage(final String text) {
		jmsTemplate.send(queueTextDestination, (session) -> {
			return session.createTextMessage(text);
		});
	}
}
